import { NewTask } from "."
import { useAppDispatch } from "@/hook/useRedux";
import { addSubTask } from "@/redux/tasks/tasksSlice";
import { useState } from "react";

interface Props {
  parentId: number;
  setOpen(bool: boolean): void
  aiShow?: boolean
  columnId: number
}

export const NewSubTask = ({ parentId, setOpen, aiShow = true, columnId }: Props) => {
  const dispatch = useAppDispatch()
  const [sendBtn, setSendBtn] = useState(false)

  const postTask = (other: any) => {
    dispatch(addSubTask({ other, parentId, columnId })).then(() => {
      setOpen(false)
      setSendBtn(false)
    })
  }

  return <NewTask setOpen={setOpen} postTask={postTask} setSendBtn={setSendBtn} sendBtn={sendBtn} aiShow={aiShow} />
}